package com.example.zzl.view.fragment.UserFragment;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.zzl.R;

import java.util.List;

/**
 * Created by Administrator on 2017/2/14.
 */
public class UserGvAdapter extends BaseAdapter{
    private Context context;
    private List<String> list;
    private List<Integer>list1;

    public UserGvAdapter(Context context, List<String> list, List<Integer> list1) {
        this.context = context;
        this.list = list;
        this.list1 = list1;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder vh;
        if (convertView==null){
            vh=new ViewHolder();
            convertView=View.inflate(context, R.layout.user_gvitem,null);
            vh.iv=(ImageView)convertView.findViewById(R.id.iv);
            vh.tv=(TextView)convertView.findViewById(R.id.tv);

            convertView.setTag(vh);
        }else {
            vh=(ViewHolder)convertView.getTag();
        }
        vh.tv.setText(list.get(position));
        vh.tv.setTextSize(20);

        vh.iv.setImageResource(list1.get(position));
        return convertView;
    }
    class ViewHolder{
        ImageView iv;
        TextView tv;
    }
}
